<div class="layui-container fly-marginTop fly-user-main">

  {include file='common/Usermenu'/}


  <!-- 移动端按钮 -->
  <div class="site-tree-mobile layui-hide">
      <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>

  <div class="site-tree-mobile layui-hide">
      <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>


  <div class="fly-panel fly-panel-user" pad20>
      <!--
    <div class="fly-msg" style="margin-top: 15px;">
      您的邮箱尚未验证，这比较影响您的帐号安全，<a href="activate.html">立即去激活？</a>
    </div>
    -->
      <div class="layui-tab layui-tab-brief" lay-filter="user">
          <ul class="layui-tab-title" id="LAY_mine">
              <li data-type="collection" data-url="/collection/find/" class="layui-this" lay-id="collection">我收藏的帖（<span>{$postssun}</span>）</li>
          </ul>
          <div class="layui-tab-content" style="padding: 20px 0;">
            
              <div class="layui-tab-item layui-show">
                  <ul class="mine-view jie-row">
                      {foreach($posrCollt as $item)}
                      <li>
                          <a class="jie-title" href="{:url('home/index/info', ['postid' => $item['postid']])}" target="_blank">{$item.post.title}</a>
                          <span class="layui-btn layui-btn-xs jie-admin layui-bg-black" type="edit" id="CollectDel" datadel="{$item['postid']}">
                              <a href="javascript:void(0)" style="color: white;padding-right: 0;" >取消收藏</a>
                          </span>
                          <i>收藏于{:Tiemstr($item.createtime)}</i>
                          <em>访问量{:commsun($item.post.visit)}</em>
                        </li>
                      {/foreach}
                  </ul>
                  <div id="LAY_page">{$pagestr}</div>
              </div>
          </div>
      </div>
  </div>
</div>

<script>
  layui.use('layer', function () {
  var layer = layui.layer
  var $ = layui.jquery

      //取消收藏
      $('#CollectDel').on('click', function () {
          var postid =  $(this).attr('datadel')

      //发送异步请求
      $.ajax({
          url: `{:url('home/collect/del')}`,
          type: 'post',
          data: `postid=`+postid,
          dataType: 'json',
          success: function (success) {
          if (success.result) {
              //成功
              layer.msg(success.msg, {
              icon: 1,
              time: 2000 //2秒关闭（如果不配置，默认是3秒）
              }, function () {
              //直接刷新界面
              location.reload()
              })
          } else {
              //失败
              layer.msg(success.msg)
          }
          }
      })
      })
  })
</script>